﻿using System;
using System.Threading;

namespace PoolKit
{
    /// <summary>
    /// Command processor. Meant to work asynchronously in most implementations. Can queue commands, run them when a handle
    /// is signalled or when specified amount of time elapses.
    /// </summary>
    internal interface ICommandProcessor : IDisposable
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandToEnqueue"></param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ObjectDisposedException"></exception>
        void EnqueueCommand(Command commandToEnqueue);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="handleToWaitOn"></param>
        /// <param name="commandToRunWhenHandleSignals"></param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ObjectDisposedException"></exception>
        void RegisterCommandWaitingForHandleSignal(WaitHandle handleToWaitOn, Command commandToRunWhenHandleSignals);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandToRun"></param>
        /// <param name="amountOfTimeToWaitBeforeRunningCommand"></param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <exception cref="ObjectDisposedException"></exception>
        void RegisterDelayedCommand(Command commandToRun, TimeSpan amountOfTimeToWaitBeforeRunningCommand);
    }
}